<!DOCTYPE html>
<html>
	<head>  
	    <meta charset="UTF-8">  
	    <title>星语乐章登录界面</title>
	    <link rel="stylesheet" type="text/css" href="/user/css/login.css"/>
	</head>  
	<body>  
	    <div id="login">  
	        <h1>Login</h1>  
	        <form method="get" enctype="multipart/form-data" onsubmit="return false">
	            <input type="text" required="required" placeholder="账号" name="account" id="account"></input>
	            <input type="password" required="required" placeholder="密码" name="password" id="password"></input>
	            <button class="but" type="submit" onclick="userLoginAccount()"><a href="javascript:void(0)">登录</a></button>
				<div style="margin-top: 10px;">
					<span class="textc" style="position: relative; float: left;">
						<a href="http://localhost/user/userIndex">返回首页</a>
					</span>
					<span  class="textc" style="position: relative; float: right;">
						<a href="userRegisterIndex">立刻注册</a>
					</span>
				</div>
	        </form>  
	    </div>  
	</body>
<!--	<script src="https://www.jq22.com/jquery/jquery-3.3.1.js"></script>-->

	<script src="/admin/assets/js/jquery-3.5.1.min.js"></script>
	<script>
		function userLoginAccount() {

			let account=$('#account').val();
			$.ajax({
				url: "userLoginAccount/"+account,
				type: "get",
				dataType: "json",
				success:function(data){
					if(data.msg =="成功"){
						console.log(data);
						userLogin();
					}else{
						alert(data.msg);
					}
				},
			})
		}

		function userLogin(){
			var account=$("#account").val();
			var password=$("#password").val();
			$.ajax({
				url: "userLoginPassword",
				type: "get",
				dataType: "json",
				data:{
					account: account,
					password: password
				},
				success:function(data){
					console.log(data);
					if(data.msg =="成功"){
						window.location.href = "/user/userIndex";
					}else{
						alert(data.msg);
					}
				},
			})
		}

	</script>
	</html>

